# -*- coding: utf-8 -*-
"""
Created on 2024-10-13 15:44:53
---------
@summary:
---------
@author: 21412
"""

import feapder
from feapder.db.mysqldb import MysqlDB
from douban_item import DoubanItem

class Douban(feapder.AirSpider):
    def start_requests(self):
        for page in range(10):
            yield feapder.Request(f"https://movie.douban.com/top250?start={page * 25}&filter=")

    def parse(self, request, response):
        li_lis = response.xpath('//*[@id="content"]/div/div[1]/ol/li')
        for li in li_lis:
            item = DoubanItem()
            item['title'] = li.xpath('./div/div[2]/div[1]/a/span[1]/text()').extract_first()
            item['rating'] = li.xpath('./div/div[2]/div[2]/div/span[2]/text()').extract_first()
            item['quote'] = li.xpath('./div/div[2]/div[2]/p[2]/span/text()').extract_first()
            print(item)
            yield item




if __name__ == "__main__":
    Douban().start()


